<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="B2B电商平台" name="description" />
<meta content="B2B电商平台" name="keyword" />

<title>B2B电商平台.店铺商品审核</title>
<link rel="icon" href="include/images/icss.ico" type="image/x-icon" />
<link rel="shortcut icon" href="include/images/icss.ico"
	type="image/x-icon" />
<link rel="stylesheet" type="text/css"
	href="<%=path %>/include/css/global.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path %>/include/css/style.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path %>/include/css/pro.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path %>/include/css/proManage.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path %>/include/css/mmt_trading.css" />

<link rel="stylesheet"
	href="<%=path %>/include/JQuery ui/css/smoothness/jquery-ui-1.7.3.custom.css"
	type="text/css"></link>
<link rel="stylesheet" type="text/css"
	href="<%=path%>/include/pagination/page.css" media="all">
<script type="text/javascript"
	src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.busin.js"></script>
<script type="text/javascript"
	src="<%=path %>/include/JQuery ui/js/jquery-ui-1.7.3.custom.min.js"></script>
<script type="text/javascript"
	src="<%=path %>/include/js/icss.common.js"></script>
<script type="text/javascript"
	src="<%=path%>/include/pagination/jquery.pagination.js"></script>
<script type="text/javascript"
	src="<%=path%>/include/pagination/init.js"></script>
<script type="text/javascript" src="<%=path%>/include/layer/layer.js"></script>	
<link href="<%=path %>/include/DatePicker/skin/WdatePicker.css" rel="stylesheet" type="text/css">
<script src="<%=path %>/include/DatePicker/WdatePicker.js" charset="UTF-8" type="text/javascript"></script>
<style type="text/css">
.price a.price_rise {
	background-position: -62px -126px;
}

.price a.price_drop {
	background-position: -62px -86px;
}

.price a.price_null {
	background-position: -1px -280px;
	padding-right: 0px;
}

.expire a.expire_drops {
	background-position: -61px -93px;
}

.expire a.expire_rise {
	background-position: -61px -134px;
}

.expire a.expire_null {
	background-position: -61px -15px;
	padding-right: 0px;
}

thead th {
	border: 1px solid #ddd;
	font-weight: bold;
}

#auditGoodsList a {
	text-decoration: none;
}

#auditGoodsList td {
	padding: 4px 4px;
	border: 1px solid #ddd;
}
#lie th{
    border: 1px solid #ddd;

}
.search_lis_se input{
    height:24px;
}
.save{
    width:44px;
    height:24px;
    line-height:24px;   
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: 0 -203px;
    border:0;
    cursor:pointer;
    font: 12px/1.5 arial,tahoma,\5b8b\4f53;
    margin: 0 0 0 5px;
    outline:none;
    background-image: url('<%=path%>/include/css/img/xs_bgx.png');   
}

button {
	width: 44px;
    height: 24px;
    line-height: 24px;
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: 0 -203px;
    border: 0;
    cursor: pointer;
    font: 12px/1.5 arial,tahoma,\5b8b\4f53;
    margin: 0 0 0 5px;
    outline: none;
    background-image: url('<%=path%>/include/css/img/xs_bgx.png');
}
th{
	text-align:center;vertical-align: middle
}
</style>

<script type="text/javascript">
	$(document).ready(function() {
		_queryList();
	});
	//进入商品详细页面
	 function toView(id,status,uuid){
    	window.location.href ="<%=path%>/productPublish/toProductPublishInfoPage.do?pageFlag=info&productId="+id+"&auditStatus="+status+"&uuid="+uuid;
    }
	
	//全选
    function selectAlledTop(){
    	if($("#topCheckAll").attr("checked")=="checked"){
		    $("input[name='productId']").each(function(index,item){
	    	 	 if($(this).is(':disabled')){
                     $(this).prop('checked',false);
                 }else{
                 	  $(this).attr("checked",true);
                 }
		    })
    	}else{
		    $("input[name='productId']").each(function(index,item){
		    	 if($(this).is(':disabled')){
                     $(this).prop('checked',false);
                 }else{
                 	  $(this).attr("checked",false);
                 }
		    })
    	}
    }
    
    var pagination;
    //查询审核列表
	function _queryList(){
		var title = $("#queryTitle").val();
		var frmStartTime = $("#frmStartTime").val();
	    var frmEndTime = $("#frmEndTime").val();
	    if(frmStartTime>frmEndTime){
		    if(frmEndTime !=null&&frmEndTime !=""&&frmEndTime !="undefined"){
		    	parent.swal("开始时间不可以大于结束时间!");
		    	return;
		    }
		}  
		var auditStatus = $("#auditStatus").val(); 
		var url = "<%=path %>/auditGoods/queryAuditGoods.do?title="+title+"&frmStartTime="+frmStartTime+"&frmEndTime="+frmEndTime+"&auditStatus="+auditStatus;
  		pagination = _initPagination({'pageId':'pagination', 'cKey':'','url': url, 'rows': 5, 'callback':_initDataList});
  		
	}
	function _initDataList(data) {
	 		var d = data.rows;
	 		var total = data.total;
			var str = "";
			$("#auditGoodsList").empty();
			for(var i=0;i<d.length;i++){
				str += "<tr>";
				str += "    <td class='t1' style='text-align:center;vertical-align: middle'>";
				if(d[i].STATUS=='1'||d[i].STATUS=='2'){
					str += " 		<input type='checkbox' name='productId' disabled='disabled' value='"+d[i].UUID+"' star='3' mainpro=''>";
				}else if(d[i].STATUS=='0'){
					str += " 		<input type='checkbox' name='productId' value='"+d[i].UUID+"' star='3' mainpro=''>";
				}
				str += "    </td>";
				str += "    <td class='t2' style='text-align:center;vertical-align: middle'>";
				str += "    		<a href='javascript:toView(\""+d[i].PRODUCT_ID+"\",\""+d[i].STATUS+"\",\""+d[i].UUID+"\")' target='_blank'>";
				if(d[i].PRODUCT_PIC==undefined){
					str += "        		<img src='<%=path%>/download/error/nopicture.jpg' width='40' height='40' alt='' resizeimg='true' onmousedown='' onerror='javascript:this.src=\"<%=path%>/download/error/nopicture.jpg\";' style='width: 50px; height: 43.5px;'>";
				} else {
					str += "        		<img src='"+d[i].PRODUCT_PIC+"' width='40' height='40' alt='' resizeimg='true' onmousedown='' onerror='javascript:this.src=\"<%=path%>/download/error/nopicture.jpg\";' style='width: 50px; height: 43.5px;'>";
				}
				str += "    		</a>";
				str += "	</td>";
				str += " 	<td class='t3' style='text-align:left;vertical-align: middle'>";
				str += "			<a href='javascript:toView(\""+d[i].PRODUCT_ID+"\",\""+d[i].STATUS+"\",\""+d[i].UUID+"\")' target='_blank'>"+d[i].PRODUCT_NAME+"</a>";
				str +=" 	</td>";
				str +="		<td class='t2' style='text-align:right;vertical-align: middle'>"+d[i].PRODUCT_PRICE+"元";
				str +="		</td>";
				str +="		<td class='t4' id='pubdateTd'  style='text-align:center;vertical-align: middle'>"+d[i].CREATE_TIME;
				str +=" 	</td>";
				if(d[i].STATUS=='0'){
					str +="		<td class='t3' id='pubdateTd'  style='text-align:center;vertical-align: middle'><a href='javascript:_audit(\""+ d[i].UUID +"\",\"noBatch\")' >待审核</a></td>";
				}else if(d[i].STATUS=='1'){
					str +="		<td class='t3' id='pubdateTd'  style='text-align:center;vertical-align: middle'>审核通过</td>";
				}else if(d[i].STATUS=='2'){
					str +="		<td class='t3' id='pubdateTd'  style='text-align:center;vertical-align: middle'>审核不通过</td>";
				}
//				str +=" 	<td class='t3' style='text-align:center;vertical-align: middle'>";
//				if(d[i].STATUS=='0'){
//					str +="    		<p><a href='javascript:_audit(\""+ d[i].UUID +"\",\"noBatch\")' >审核</a>";
//					str +=" 		</p>";
//				}else if(d[i].STATUS=='1'){
				//	str +="    		<p><span style='color:#3B3B3B;'>审核通过</span>";
				//	str +=" 		</p>";
//				}else if(d[i].STATUS=='2'){
				//	str +="    		<p><span>审核不通过</span>";
				//	str +=" 		</p>";
//				}
//				str +=" 	</td>";	                
				str +=" </tr>";
			}
			$("#auditGoodsList").append(str);
			setTimeout(function(){_reHeight("rightFrame","contentDiv");},1000);
			
	 }
	 //批量审核
	 function auditAbove(){
	    var priceIds =""
    	 $("input[name='productId']").each(function(index,item){
    		 if($(this).attr("checked")=="checked"){
    			 priceIds += $(this).val()+",";
        	 }
	    })
	    if(priceIds==""){
		   parent.layer.alert("请至少选择一条记录!");
		    return;
		}else{
			_audit(priceIds,'batch');
		 }
	 }
	//进入审核页面
	function _audit(uuid,ifBatch){
		var url = "<%=path%>/auditGoods/toAuditGoodPage.do";
		var title = "";
		if(ifBatch == 'batch'){		//批量审核
			title = '批量审核操作';
		}else if(ifBatch == 'noBatch'){//单个商品审核
			title = '审核操作';
		}
		parent.layer.open({
			title:title,
			type: 2,
			fixed: false, //不固定
			offset: '100px',
			area: ['460px', '290px'],
			shadeClose: false, //点击遮罩关闭
			content: url,
			btn: ['确定', '取消'],
			yes: function(index, layero){
				//按钮【按钮一】的回调
				var body = layer.getChildFrame('body', index);
				//var iframeWin = window[layero.find('iframe')[0]['name']];   //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
				var iframeWin = $(layero).find("iframe")[0].contentWindow;
				//iframeWin.setValues();
				var flag = iframeWin._checkReason();//验证审核不通过时，是否填写不通过原因
				if(flag){
					var refundType = iframeWin.getRefundType();//$("#refundType").val();
					var rejectReason = iframeWin.getrRejectReason();//$("#rejectReason").val();
					if(ifBatch == 'batch'){		//批量审核
						_auditIfBatch(uuid, rejectReason,refundType,ifBatch);
					}else if(ifBatch == 'noBatch'){//单个商品审核
						_auditIfBatch(uuid, rejectReason,refundType, ifBatch);
					}
					
				}
				
			},
			btn2: function(index, layero){
				//按钮【按钮二】的回调
				//return false 开启该代码可禁止点击该按钮关闭
			},
			maxmin:true
		});
	}
	//审核操作
	function _auditIfBatch(uuid, rejectReason,refundType, ifBatch){
		$.ajax({
	 		type:"GET",
			url:"<%=path%>/auditGoods/auditIfBatch.do",
			data: {
				uuid:uuid,
				rejectReason : rejectReason,
				refundType : refundType,
				ifBatch : ifBatch
			},
			dataType:"json",
			async : false, //同步执行
			success:function(data){
				if(data.success){
					if(ifBatch == 'batch'){
						parent.swal("批量审核成功!", "", "success");
					}else if(ifBatch == 'noBatch'){
						parent.swal("审核成功!", "", "success");
					}
					 $("#topCheckAll").attr("checked",false);
					_queryList();
					setTimeout(parent.layer.closeAll(),3000);
				} else {
					if(ifBatch == 'batch'){
					 	parent.swal("OMG", "批量审核失败！", "error");
					}else if(ifBatch == 'noBatch'){
						parent.swal("OMG", "审核失败！", "error");
					}
					 $("#topCheckAll").attr("checked",false);
				}
			},error:function(data){
			}
	 	});
	}
</script>
</head>
<body>
	<div id="contentDiv" style="padding:4px; width:99%;font-family: '微软雅黑';">
		<input type="hidden" id="refundType" name="refundType"/>
		<input type="hidden" id="rejectReason" name="rejectReason"/>
		<div class="colnums-2-ab-b" style="overflow-x:auto;">
			<div class="toptil" >审核商品</div>
			<div class="search_lis" style="border: 1px solid #e0e0e0;background: #f5f5f5;padding-left:10px;margin-bottom:10px;width:98.5%;height: 30px;">
				<div class="search_lis_se" style="font-size: 14px;">
					<span>商品标题:</span> 
					<input name="querytitle" id="queryTitle" type="text" class="in_bit" maxlength="40" value=""  placeholder="请输入商品标题..."
					 style="color:#000000;width: 120px;">
					 <span style="margin-left:5px;">申请时间: </span>
					<input type="text" id="frmStartTime" name="frmStartTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,maxDate:'#F{$dp.$D(\'frmEndTime\')}'})" style="width: 110px;height: 24px; padding-left: 3px" onfocus="WdatePicker({position:{left:315,top:88}})" class="Wdate" value="" realvalue="">
					<span style="margin-left: 5px;">至</span>
					<input type="text" id="frmEndTime" name="frmEndTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,minDate:'#F{$dp.$D(\'frmStartTime\')}'})" style="width: 110px;height: 24px; padding-left: 3px;margin-right: 2px;" onfocus="WdatePicker({position:{left:464,top:88}})" class="Wdate" value="" realvalue="">
					<span style="margin-left:5px;">审核状态:</span> 
					<select id="auditStatus" name="auditStatus" style="color:#000000;width: 94px;height:24px;"  autocomplete="off">
						<option value="">全部</option>
						<option value="0" selected>待审核</option>
						<option value="1">审核通过</option>
						<option value="2">审核不通过</option>
					</select>
					<button type="button" class="save" onclick="_queryList()">查询</button>
					<button type="button" style="width:66px;height:24px;background-size: 180px 458px;" onclick="javascript:auditAbove()">批量审核</button>
				</div>
				<div class="wantBuy" id="caigouInfo"></div>
			</div>
			<div class="listed_tb_k" style="width:99.65%; border: none;">
				<table cellspacing="0" cellpadding="0">
					<thead>
						<!-- <tr>
							<th colspan="7" style="background-color: white;">
								<div class="list_table_bot" style="margin: 0px;padding: 0px;">
									<div style="margin-bottom: 7px;text-align: left;">
										<label>
											<input id="topCheckAll" name="topCheckAll"
											type="checkbox" onclick="selectAlledTop()" class="chk">全选
										</label>&nbsp;
										<button class="gray_btn" type="button" style="width:80px;height:24px;" onclick="javascript:auditAbove()">批量审核</button>
									</div>
								</div>
							</th>
						</tr> -->
						<tr id="lie">
							<th class="t1"><input id="topCheckAll" name="topCheckAll" type="checkbox" onclick="selectAlledTop()" class="chk"></th>
							<th class="t2">图片</th>
							<th class="t3">标题</th>
							<th class="t2">价格</th>
							<th class="t4">申请日期</th>
							<th class="t3">状态/操作</th>
						</tr>
					</thead>
					<tbody id="auditGoodsList">
					</tbody>
				</table>
				<div id="pagination"></div>
			</div>
		</div>
		<div class="clear"></div>
	</div>
</body>
<script type="text/javascript">
	$(document).ready(function() {
		_reHeight("rightFrame", "contentDiv");
	});
</script>
</html>
